// 1. This do-file contains code for running the event study regressions for our main specifications, as well as robustness checks and regressions for demographic subgroups. All of the estimates are stored in macros and are then saved in a separate dataset at the end. 

**** Set globals 
set more off
clear all

global dir_data "[FILL IN]" // FILL IN WITH FOLDER PATH FOR MAIN FILES
global temp "`c(tmpdir)'"

cd "${dir_data}"

****************************************
******Main Event Study Regressions******
****************************************
**** Main regressions
foreach prog in di wc vet ui snap tanf med ssi wic {
	use "sipp_sample_analysis", clear	
	
	** Keep relevant sample
	keep if (months_since`prog'_min<0 & months_since`prog'_min!=.)
	keep if (months_since`prog'>=-15 & months_since`prog'<=16)

	** Construct group indicators
	qui gen cohort_temp = year_month if months_since`prog'==0
	egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
	drop cohort_temp	
	format %tm cohort

	** Construct quarter-level variables
	qui gen quarters_since = .
	qui replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
	qui replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
	qui replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
	qui replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
	qui replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
	qui replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
	qui replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
	qui replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
	qui replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
	qui replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
	qui replace quarters_since = 5 if inlist(months_since`prog',15,16)
	
	gen quarters_since_norm = quarters_since + 5
	
	forvalues i = 0/10 {
		gen quarters_since_norm`i' = (quarters_since_norm==`i')
	}

	** Main regressions
	foreach var in thmktinc_pov thallinc_pov unemployed_any nilf_25to59_any ///
		notworking_any kid_0to4_any disabled_any sepdivwid_any ///
		di_rec wc_rec ui_rec snap_rec tanf_rec med_rec ssi_rec wic_rec {
		qui reghdfe `var' quarters_since_norm0 ///
			quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
			absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
				
		* Globals 		
		foreach i of numlist 0 2/10 {
			global b_`var'_q`i' = _b[quarters_since_norm`i']
			global se_`var'_q`i' = _se[quarters_since_norm`i']	
			
			global b_`var'_`prog'_q`i' = _b[quarters_since_norm`i']
			global se_`var'_`prog'_q`i' = _se[quarters_since_norm`i']	
		}
			
		* Means for 4 quarters pre
		qui sum `var' if quarters_since==-4 [aw=whfnwgt], detail
		global `var'_`prog'_mean = r(mean)	
		global `var'_`prog'_mean_round:  di %3.2f ${`var'_`prog'_mean}
	}

	** Robustness checks for income variables 
	foreach var in thmktinc_pov {
		* Cohort FEs 
		qui reghdfe `var' quarters_since_norm0 ///
			quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
			absorb(cohort rhcalyr rhcalmn) vce(cluster cohort) 
		
		foreach i of numlist 0 2/10 {
			global b_cohfe_`var'_q`i' = _b[quarters_since_norm`i']
			global se_cohfe_`var'_q`i' = _se[quarters_since_norm`i']				
		}			
		
		* Probit 
		replace `var' = 0 if `var'<0
		
		qui ppmlhdfe `var' quarters_since_norm0 ///
			quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
			absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
			
		foreach i of numlist 0 2/10 {
			global b_pois_`var'_q`i' = _b[quarters_since_norm`i']
			global se_pois_`var'_q`i' = _se[quarters_since_norm`i']				
		}	
		
		* Zero-inflated probit 
		cap qui zip `var' quarters_since_norm0 ///
			quarters_since_norm2 quarters_since_norm3 quarters_since_norm4 ///
			quarters_since_norm5 quarters_since_norm6 quarters_since_norm7 ///
			quarters_since_norm8 quarters_since_norm9 quarters_since_norm10 unemp_rate ///
			i.cohort i.rhcalyr i.rhcalmn [pw=whfnwgt], ///
			inflate(_cons) vce(cluster cohort) 	
			
		foreach i of numlist 0 2/10 {
			global b_zip_`var'_q`i' = _b[quarters_since_norm`i']
			global se_zip_`var'_q`i' = _se[quarters_since_norm`i']				
		}				
	}

	** Store regression estimates
	clear 
	set obs 11

	* Construct window
	qui gen quarters_since`prog'_norm = .

	foreach j of numlist 0 2/10 {
		local k = `j' + 1
		qui replace quarters_since`prog'_norm = `j' in `k'
	}

	replace quarters_since`prog'_norm = 1 in 2
	gen quarters_since`prog' = quarters_since`prog'_norm - 5

	* Fill in variables 
	foreach var in thmktinc_pov thallinc_pov pois_thmktinc_pov zip_thmktinc_pov ///
	cohfe_thmktinc_pov kid_0to4_any employed_any disabled_any sepdivwid_any ///
	unemployed_any nilf_25to59_any notworking_any ///
	di_rec wc_rec vet_rec ui_rec snap_rec tanf_rec med_rec ssi_rec wic_rec {
		qui gen b_`var' = .
		qui gen se_`var' = .
		qui gen ci95lb_`var' = .
		qui gen ci95ub_`var' = .
			
		foreach j of numlist 0 2/10 {
			local k = `j' + 1
			qui replace b_`var' = ${b_`var'_q`j'} in `k'
			qui replace se_`var' = ${se_`var'_q`j'} in `k'
			qui replace ci95lb_`var' = ${b_`var'_q`j'} - 1.96*${se_`var'_q`j'} in `k'
			qui replace ci95ub_`var' = ${b_`var'_q`j'} + 1.96*${se_`var'_q`j'} in `k'
		}
			
		qui replace b_`var' = 0 in 2
		qui replace se_`var' = 0 in 2
		qui replace ci95lb_`var' = 0 in 2
		qui replace ci95ub_`var' = 0 in 2					
	}
		
	* Save 
	drop quarters_since`prog'_norm	
	compress
	save "${temp}/`prog'_regs", replace		
}

*****************************************
******Event Study Robustness Checks******
*****************************************
**** Appearing in 36 consecutive months)
foreach prog in snap med ui {
	use "sipp_sample_analysis", clear		

	** Keep households in 36 consecutive months 
	gen max_wave_temp = (min_wave + swave_count) - 1
	gen match = (max_wave==max_wave_temp)
	
	keep if (swave_count>=9 & match==1 & inlist(spanel,1996,2001,2004,2008)) | ///
		(swave_count>=3 & match==1 & inlist(spanel,2014,2018))
		
	** Keep relevant sample
	keep if (months_since`prog'_min<0 & months_since`prog'_min!=.) 
	keep if (months_since`prog'>=-15 & months_since`prog'<=16) 
	
	** Construct group indicators
	qui gen cohort_temp = year_month if months_since`prog'==0
	egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
	drop cohort_temp	
	format %tm cohort	

	** Construct quarter-level variables
	qui gen quarters_since = .
	qui replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
	qui replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
	qui replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
	qui replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
	qui replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
	qui replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
	qui replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
	qui replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
	qui replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
	qui replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
	qui replace quarters_since = 5 if inlist(months_since`prog',15,16)
		
	gen quarters_since_norm = quarters_since + 5
		
	forvalues i = 0/10 {
		gen quarters_since_norm`i' = (quarters_since_norm==`i')
	}

	** Main regressions
	foreach var in thmktinc_pov {
		qui reghdfe `var' quarters_since_norm0 ///
			quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
			absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
				
		foreach i of numlist 0 2/10 {
			global b_`var'_q`i'_36mo = _b[quarters_since_norm`i']
			global se_`var'_q`i'_36mo = _se[quarters_since_norm`i']				
		}
		
		* Means for 4 quarters pre
		qui sum `var' if quarters_since==-4 [aw=whfnwgt], detail
		global `var'_36mo_`prog'_mean = r(mean)
		global `var'_36mo_`prog'_med = r(p50)		
	}	
}

**** Restricting to 1996-2008 Panels
foreach prog in snap med ui {
	use "sipp_sample_analysis", clear	
	
	** Keep relevant panels 
	keep if inlist(spanel,1996,2001,2004,2008)
		
	** Keep relevant sample
	keep if (months_since`prog'_min<0 & months_since`prog'_min!=.) 
	keep if (months_since`prog'>=-15 & months_since`prog'<=16) 
	
	** Construct group indicators
	qui gen cohort_temp = year_month if months_since`prog'==0
	egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
	drop cohort_temp	
	format %tm cohort	

	** Construct quarter-level variables
	qui gen quarters_since = .
	qui replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
	qui replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
	qui replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
	qui replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
	qui replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
	qui replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
	qui replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
	qui replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
	qui replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
	qui replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
	qui replace quarters_since = 5 if inlist(months_since`prog',15,16)
		
	gen quarters_since_norm = quarters_since + 5
		
	forvalues i = 0/10 {
		gen quarters_since_norm`i' = (quarters_since_norm==`i')
	}

	** Main regressions
	foreach var in thmktinc_pov {
		qui reghdfe `var' quarters_since_norm0 ///
			quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
			absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
				
		foreach i of numlist 0 2/10 {
			global b_`var'_q`i'_9608 = _b[quarters_since_norm`i']
			global se_`var'_q`i'_9608 = _se[quarters_since_norm`i']				
		}
		
		* Means for 4 quarters pre		
		qui sum `var' if quarters_since==-4 [aw=whfnwgt], detail
		global `var'_9608_`prog'_mean = r(mean)
		global `var'_9608_`prog'_med = r(p50)		
	}	
}
		
**** Different pre-period samples
foreach l in 2 4 {
	foreach prog in snap med ui {
		use "sipp_sample_analysis", clear	
		
		** Keep relevant sample
		local m = `l'*(-4)
		
		keep if months_since`prog'_min<`m' & months_since`prog'_min!=.
		keep if (months_since`prog'>=-15 & months_since`prog'<=16)
		
		** Construct group indicators
		qui gen cohort_temp = year_month if months_since`prog'==0
		egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
		drop cohort_temp	
		format %tm cohort		

		** Construct quarter-level variables
		qui gen quarters_since = .
		qui replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
		qui replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
		qui replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
		qui replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
		qui replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
		qui replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
		qui replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
		qui replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
		qui replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
		qui replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
		qui replace quarters_since = 5 if inlist(months_since`prog',15,16)
		
		gen quarters_since_norm = quarters_since + 5
		
		forvalues i = 0/10 {
			gen quarters_since_norm`i' = (quarters_since_norm==`i')
		}

		** Main regressions
		foreach var in thmktinc_pov {
			qui reghdfe `var' quarters_since_norm0 ///
				quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
				absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
					
			foreach i of numlist 0 2/10 {
				global b_`var'_q`i'_pre`l' = _b[quarters_since_norm`i']
				global se_`var'_q`i'_pre`l' = _se[quarters_since_norm`i']				
			}
			
			* Means for 4 quarters pre		
			qui sum `var' if quarters_since==-4 [aw=whfnwgt], detail
			global `var'_pre`l'_`prog'_mean = r(mean)
			global `var'_pre`l'_`prog'_med = r(p50)		
		}	
	}	
}

**** Different pre- and post-period samples
foreach l in 2 4 {
	foreach prog in snap med ui {
		use "sipp_sample_analysis", clear	
		
		** Keep relevant sample
		local m = `l'*(-4)
		local n = `l'*(4)		
		
		keep if (months_since`prog'_min<`m' & months_since`prog'_min!=.) & ///	
			(months_since`prog'_max>=`n' & months_since`prog'_max!=.)	
		keep if (months_since`prog'>=-15 & months_since`prog'<=16)
		
		** Construct group indicators
		qui gen cohort_temp = year_month if months_since`prog'==0
		egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
		drop cohort_temp	
		format %tm cohort		

		** Construct quarter-level variables
		qui gen quarters_since = .
		qui replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
		qui replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
		qui replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
		qui replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
		qui replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
		qui replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
		qui replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
		qui replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
		qui replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
		qui replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
		qui replace quarters_since = 5 if inlist(months_since`prog',15,16)
		
		gen quarters_since_norm = quarters_since + 5
		
		forvalues i = 0/10 {
			gen quarters_since_norm`i' = (quarters_since_norm==`i')
		}

		** Main regressions
		foreach var in thmktinc_pov {
			qui reghdfe `var' quarters_since_norm0 ///
				quarters_since_norm2-quarters_since_norm10 unemp_rate [pw=whfnwgt], ///
				absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
					
			foreach i of numlist 0 2/10 {
				global b_`var'_q`i'_dou`l' = _b[quarters_since_norm`i']
				global se_`var'_q`i'_dou`l' = _se[quarters_since_norm`i']				
			}
			
			* Means for 4 quarters pre	
			qui sum `var' if quarters_since==-4 [aw=whfnwgt], detail
			global `var'_dou`l'_`prog'_mean = r(mean)
			global `var'_dou`l'_`prog'_med = r(p50)		
		}
	}
}

**** Store regression estimates
foreach prog in snap med ui {
	clear 
	set obs 11

	* Construct window
	qui gen quarters_since`prog'_norm = .

	foreach j of numlist 0 2/10 {
		local k = `j' + 1
		qui replace quarters_since`prog'_norm = `j' in `k'
	}

	replace quarters_since`prog'_norm = 1 in 2
	gen quarters_since`prog' = quarters_since`prog'_norm - 5

	* Fill in variables 
	foreach var in thmktinc_pov {
		foreach type in "36mo" "9608" "pre2" "pre4" "dou2" "dou4" {
			qui gen b_`var'_`type' = .
			qui gen se_`var'_`type' = .
			qui gen ci95lb_`var'_`type' = .
			qui gen ci95ub_`var'_`type' = .
				
			foreach j of numlist 0 2/10 {
				local k = `j' + 1
				qui replace b_`var'_`type' = ${b_`var'_q`j'_`type'} in `k'
				qui replace se_`var'_`type' = ${se_`var'_q`j'_`type'} in `k'
				qui replace ci95lb_`var'_`type' = ${b_`var'_q`j'_`type'} - ///
					1.96*${se_`var'_q`j'_`type'} in `k'
				qui replace ci95ub_`var'_`type' = ${b_`var'_q`j'_`type'} + ///
					1.96*${se_`var'_q`j'_`type'} in `k'
			}
				
			qui replace b_`var'_`type' = 0 in 2
			qui replace se_`var'_`type' = 0 in 2
			qui replace ci95lb_`var'_`type' = 0 in 2
			qui replace ci95ub_`var'_`type' = 0 in 2					
		}			
	}

		
	* Save 
	drop quarters_since`prog'_norm	
	compress
	save "${temp}/`prog'_regs_rc", replace	
}

*************************************************
******Regressions (by Demographic Subgroup)******
*************************************************
cd "${dir_data}"

**** Regressions
foreach prog in snap med ui {
	use "sipp_sample_analysis", clear	
	
	** Keep relevant sample
	keep if months_since`prog'_min<0 & months_since`prog'_min!=.
	keep if (months_since`prog'>=-15 & months_since`prog'<=16)
	
	** Construct group indicators
	qui gen cohort_temp = year_month if months_since`prog'==0
	egen cohort = max(cohort_temp), by(spanel ssuid shhadid)
	drop cohort_temp	
	format %tm cohort	
	
	** Construct quarter-level variables
	gen quarters_since = .
	replace quarters_since = -5 if inlist(months_since`prog',-15,-14,-13)
	replace quarters_since = -4 if inlist(months_since`prog',-12,-11,-10)
	replace quarters_since = -3 if inlist(months_since`prog',-9,-8,-7)
	replace quarters_since = -2 if inlist(months_since`prog',-6,-5,-4)	
	replace quarters_since = -1 if inlist(months_since`prog',-1,-2,-3)
	replace quarters_since = 0 if inlist(months_since`prog',0,1,2)
	replace quarters_since = 1 if inlist(months_since`prog',3,4,5)
	replace quarters_since = 2 if inlist(months_since`prog',6,7,8)
	replace quarters_since = 3 if inlist(months_since`prog',9,10,11)
	replace quarters_since = 4 if inlist(months_since`prog',12,13,14)
	replace quarters_since = 5 if inlist(months_since`prog',15,16)
	
	gen quarters_since_norm = quarters_since + 5
	
	forvalues i = 0/10 {
		gen quarters_since_norm`i' = (quarters_since_norm==`i')
	}
	
	** Designate characteristics for 12 months pre-receipt 
	foreach var in white_nonhisp black_nonhisp hispanic lessthanhs hs_grad college ///
	hh_eld hh_withchild_noeld hh_nochild_noeld {
		qui gen `var'_pre_temp = `var' if months_since`prog'==-12 
		qui egen `var'_pre = mean(`var'_pre_temp), by(spanel ssuid)
		drop `var'_pre_temp 
	}
	
	rename white_nonhisp_pre white_pre 
	rename black_nonhisp_pre black_pre
	rename hispanic_pre hisp_pre
	rename lessthanhs_pre lesshs_pre 
	rename hs_grad_pre hsgrad_pre
	rename hh_eld_pre eld_pre 
	rename hh_withchild_noeld_pre wchild_pre
	rename hh_nochild_noeld_pre nchild_pre

	** Main regressions
	drop kid_0to4 disabled sepdivwid thmktinc thallinc notworking
	rename thmktinc_pov thmktinc
	
	foreach var in thmktinc  {
		foreach char in white black hisp lesshs hsgrad college eld wchild nchild {
			qui reghdfe `var' quarters_since_norm0 ///
				quarters_since_norm2-quarters_since_norm10 unemp_rate ///
				if `char'_pre==1 [pw=whfnwgt], ///
				absorb(hh_id rhcalyr rhcalmn) vce(cluster cohort) 
	
			global b_`var'_`prog'_`char'_q5 = _b[quarters_since_norm5]
			global se_`var'_`prog'_`char'_q5 = _se[quarters_since_norm5]				
		}
	}		
	
	** Get summary stats for 4 quarters pre 
	foreach var in thmktinc {
		foreach char in white black hisp lesshs hsgrad college eld wchild nchild {
			qui sum `var' if inlist(months_since`prog',-12,-11,-10) ///
				& `char'_pre==1 [aw=whfnwgt], detail
			global `var'_`prog'_`char'_mean = r(mean)
			global `var'_`prog'_`char'_med = r(p50)
		}
	}
	
	** Scale by summary stats
	foreach var in thmktinc {
		foreach char in white black hisp lesshs hsgrad college eld wchild nchild {
			global b_`var'_`prog'_`char'_q5 = ///
				${b_`var'_`prog'_`char'_q5}/${`var'_`prog'_`char'_mean}
			global se_`var'_`prog'_`char'_q5 = ///
				${se_`var'_`prog'_`char'_q5}/${`var'_`prog'_`char'_mean}		
		}
	}
}

*************************************************
******Combine Estimates into Single Dataset******	
*************************************************
**** Combine quarterly regression estimates for each program 
foreach prog in snap tanf med ssi wc vet ui di wic {
	use "${temp}/`prog'_regs", clear
	
	** Bring in robustness checks 
	if "`prog'"=="snap" | "`prog'"=="med" | "`prog'"=="ui" {
		merge 1:1 quarters_since`prog' using "${temp}/`prog'_regs_rc", nogen		
	}

	sort quarters_since`prog'
	drop ci95*
	
	** Rename variables
	rename quarters_since`prog' quarters
	
	qui ds quarters, not
	foreach var of varlist `r(varlist)' {
		rename `var' `var'_`prog'
	}
	
	** Save temporary file 
	save "${temp}/`prog'_regs_rev", replace
}

**** Merge across programs files to create master file of estimates
use "${temp}/snap_regs_rev", clear
	
foreach prog in tanf med wc vet ui di ssi wic /* hous */ {
	merge 1:1 quarters using "${temp}/`prog'_regs_rev", nogen
}

**** Reconfigure estimates
** Split coefficients into significant vs non-significant
foreach prog in di wc vet ui snap tanf med ssi wic {
	foreach var in thmktinc_pov thallinc_pov kid_0to4_any disabled_any ///
	sepdivwid_any unemployed_any nilf_25to59_any notworking_any ///
	di_rec wc_rec vet_rec ui_rec snap_rec tanf_rec med_rec ssi_rec wic_rec {
		gen b_`var'_`prog'_sig = b_`var'_`prog' if ///
			abs(b_`var'_`prog'/se_`var'_`prog')>=1.96	
		replace b_`var'_`prog'_sig = . if quarters==-4	
			
		gen b_`var'_`prog'_nosig = b_`var'_`prog' if ///
			abs(b_`var'_`prog'/se_`var'_`prog')<1.96	
		replace b_`var'_`prog'_nosig = b_`var'_`prog' if quarters==-4	
		
		gen b_`var'_`prog'_blank = .		
	}
}

** Calculate 95% CIs 
foreach prog in di wc vet ui snap tanf med ssi wic {
	foreach var in thmktinc_pov thallinc_pov kid_0to4_any disabled_any ///
	sepdivwid_any unemployed_any nilf_25to59_any notworking_any ///
	di_rec wc_rec vet_rec ui_rec snap_rec tanf_rec med_rec ssi_rec wic_rec {
		gen ci95lb_`var'_`prog' = b_`var'_`prog' - 1.96*se_`var'_`prog'
		gen ci95ub_`var'_`prog' = b_`var'_`prog' + 1.96*se_`var'_`prog'		
	}
}

** Re-scale incomes by baseline 
foreach prog in di wc vet ui snap tanf med ssi wic {
	foreach var in thmktinc_pov thallinc_pov {
		foreach type in b ci95lb ci95ub {
			replace `type'_`var'_`prog' = `type'_`var'_`prog'/${`var'_`prog'_mean}		
		}
		
		replace b_`var'_`prog'_sig = b_`var'_`prog'_sig/${`var'_`prog'_mean}
		replace b_`var'_`prog'_nosig = b_`var'_`prog'_nosig/${`var'_`prog'_mean}	
	}
}

**** Save file 
save "reg_estimates", replace
